package wty.framework.flow;

import wty.framework.flow.AbstractState;
import wty.framework.flow.FlowSession;
/**
 * <pre>範例：
 * WorkFlow flow = new WorkFlow();
 * while(flow.nextState());
 * </pre>
 * @author Tim Wang
 */
public class Flow {
	private AbstractState nextState;
	private FlowSession session;
	public Flow(AbstractState startState, FlowSession session) {
		this.nextState = startState;
		this.session = session;
	}
	final void setNextState(AbstractState state) {
		nextState = state;
	}
	public final boolean nextState() {
		if(nextState!=null) {
			nextState.nextState(this, session);
			return nextState!=null;
		}
		return false;
	}
	public AbstractState getCurrentState() {
		return nextState;
	}
}
